Religion is a very woolly word and to understand it we would have to define it well because it means different things to different people. It almost defies an all inclusive meaning but at its root it must have to do with a recognition of-- or obligation to a spirit world which is interactive with human life.
Looking back to the experience of our cave dwelling forebears, it can be demonstrated that they made a clear distinction between the mundane world and a sacred realm. (La Vache cave (mundane) and neighbouring cave (sacred) at Niaux in the Pyrenees, France, fourteenth century BCE) The sacred being marked by isolation from the everyday realities by using theatrical devices such as paintings, illumination and sound and holding rituals in special locations (often with cathedral like acoustics as at Niaux). For the tribal integrity certain rituals had to be observed and taboos respected. It was the hunter's relation to the sacred which explained his failures and successes. Had he observed the rites correctly? Had he consulted the shaman to intercede with the spirit masters? Had he sacrificed? Had he drained the blood of his kill? The human brain unlike the animal's, required explanations.
It became clear that as humanity veered away from brute animal kind over geological time, what distinguished the difference between the two were the strategic faculties of the human mind. A mind capable of imagination and subterfuge and deception, including self deception par excellence.
Religious observation kept the tribe psychically healthy but what worked i.e. the doctrines of the sacred, for one tribe may not have done for another and here is the rub. One set of sacred absolutes did not accord with a distant tribe's perception of what was a sacred absolute and so in the battle for survival over hunting territory, 'religion' became embroiled in the survival game. It may be argued there was an advantage to a tribe which was more religious or had a good shaman but since it is probable that all early humanity was smitten with the same bug it would be hard to determine at this distance in time.
So did religion play a part in our evolution? Meaning did religion give an evolutionary advantage to our ancestors encouraging survival?
I am inclined to think that at the tribal level it worked for internal order and submission to common values which made for unity. But that is not evolution. Instead I reckon that rather than religion being an agent for human evolution, religious thinking; the sacred and profane divide, can be shown to be the consequence of the expansion of the human cerebral cortex. (See; W. La Barre; The Human Animal)
As a final note on the value of religion, although it conceivably gave some tribes a survival advantage; what worked for the tribe did not work universally so religion was not an agent for human improvement for in its extreme manifestations, it remains today a tribal force for division and mayhem.